const express = require('express');
const router = express.Router();
const borrowController = require('../controllers/borrowController');
const returnController = require('../controllers/returnController');
const { authenticateToken } = require('../middleware/auth');

// 所有路由都需要认证
router.use(authenticateToken);

// ===== 借阅相关 =====
// 借阅图书
router.post('/', borrowController.borrowBook);

// 获取用户的借阅记录
router.get('/records', borrowController.getBorrowRecords);

// 续借图书
router.post('/renew', borrowController.renewBook);

// 获取借阅统计
router.get('/stats', borrowController.getBorrowStats);

// ===== 归还相关 =====
// 归还图书
router.post('/return', returnController.returnBook);

// 获取归还记录
router.get('/return/records', returnController.getReturnRecords);

// 获取逾期记录
router.get('/overdue', returnController.getOverdueRecords);

// 支付罚款
router.post('/pay-fine', returnController.payFine);

module.exports = router;

